/**
 * 
 */
package com.google.code.netz.wfe;

import com.google.code.netz.wfe.model.AbstractCase;
import com.google.code.netz.wfe.model.ICase;
import com.google.code.netz.wfe.model.InputArc;
import com.google.code.netz.wfe.model.OutputArc;
import com.google.code.netz.wfe.model.Place;
import com.google.code.netz.wfe.model.Transition;

/**
 * ICase that defines a process to sign up a new User.
 * 
 * @author <a href='mailto:rahul.thakur.xdev@gmail.com'>Rahul Thakur</a>
 * @since 1.0
 * @version $Id$
 */
public class SignupUserWorkflow<D> extends AbstractCase<D> implements ICase<D> {

    /* Places declaration. */
    private Place<UserData> _start = new Place<UserData>("start");
    private Place<UserData> p2 = new Place<UserData>("Valid User Details");
    private Place<UserData> p3a = new Place<UserData>("Error Saving User");
    private Place<UserData> p3b = new Place<UserData>("User saved");
    private Place<UserData> _end = new Place<UserData>("end");

    /* Transitions declaration. */
    private Transition<UserData> t1 = new Transition<UserData>(
            "Validate User Details");
    private Transition<UserData> t2 = new Transition<UserData>(
            "Save User Details");
    private Transition<UserData> t3 = new Transition<UserData>(
            "Display Result of Signup");

    /* Input Arcs and Output Arcs declaration. */
    private InputArc<UserData> i1 = new InputArc<UserData>(_start, t1);
    private OutputArc<UserData> o1 = new OutputArc<UserData>(t1, p2);

    private InputArc<UserData> i2 = new InputArc<UserData>(p2, t2);
    private OutputArc<UserData> o2a = new OutputArc<UserData>(t2, p3a);
    private OutputArc<UserData> o2b = new OutputArc<UserData>(t2, p3b);

    private InputArc<UserData> i3a = new InputArc<UserData>(p3a, t3);
    private InputArc<UserData> i3b = new InputArc<UserData>(p3b, t3);
    private OutputArc<UserData> o3 = new OutputArc<UserData>(t3, _end);

    public SignupUserWorkflow(String label) {
        super(label);
        this.register(_start).register(p2).register(p3a).register(p3b)
                .register(_end).register(t1).register(t2).register(t3)
                .register(i1).register(o1).register(i2).register(o2a).register(
                        o2b).register(i3a).register(i3b).register(o3);
    }

    @Override
    public Place getSink() {
        // TODO Auto-generated method stub
        return null;
    }

}
